package com.itheima.dao;

import com.itheima.domain.Permission;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName:PermissionDao
 * Package:com.itheima.dao
 * Description:
 * Date:2020/3/12 3:14
 * User: snow
 */
@Repository
public interface PermissionDao {

/*	@Select("select * from permission where id in " +
			"(select permissionId from role_permission where roleId = #{id})")
	@Results({
			@Result(id = true, property = "id", column = "id"),
			@Result(property = "permissionName", column = "permission_name"),
			@Result(property = "url", column = "permission_url"),
	})*/
	public List<Permission> findPermissionByRoleId(@Param("roleId") String id) throws Exception;

	// @Select("select * from permission")
	public List<Permission> findAll() throws Exception;

	// @Insert("insert into permission(permissionName,url) values(#{permissionName},#{url})")
	public void save(Permission permission) throws Exception;

	// @Select("select * from permission where id = #{id}")
	public Permission findById(String id) throws Exception;
}
